<template>
  <div>
    <def-layout type="col0-24" :page="page" @invoke="invoke">
      <div slot="search" class="form-items">
        <el-form-item>
          <el-input v-model="formSearch.supplierName" placeholder="供应商" />
        </el-form-item>
        <el-form-item>
          <el-input v-model="formSearch.accountName" placeholder="收款人" />
        </el-form-item>
        <el-form-item>
          <el-select v-model="formSearch.bankName" placeholder="收款方式">
            <el-option
              v-for="item in constants.banks"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model="formSearch.used" placeholder="状态">
            <el-option
              v-for="item in constants.used.values()"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </div>
      <div slot="content" class="grid">
        <page-grid v-if="self!=null" :parent="self">
          <div slot="columns">
            <el-table-column prop="used" align="center" label="状态" width="150">
              <template slot-scope="scope">
                <column-filter v-model="scope.row.used" type="used" @click="filter" />
              </template>
            </el-table-column>
            <el-table-column prop="supplierName" align="center" label="供应商" width="200" />
            <el-table-column prop="bankName" align="center" label="收款方式" width="150">
              <template slot-scope="scope">
                <column-filter-label v-model="scope.row.bankName" search-key="bankName" @click="filter" />
              </template>
            </el-table-column>
            <el-table-column prop="accountName" align="center" label="收款人" width="150" />
            <el-table-column prop="createTime" sortable align="center" label="创建时间" width="150" />
            <el-table-column prop="updateTime" sortable align="center" label="更新时间" width="150" />
            <el-table-column prop="creator" align="center" label="创建人" width="150" />
            <el-table-column prop="updator" align="center" label="修改人" width="150" />
          </div>
        </page-grid>
      </div>
    </def-layout>
    <editFrom ref="editDrawer" :page="page" :params="modalParams" />

  </div>
</template>
<script>
import adminSupport from 'lola-admin-support-el'
import editFrom from '@/views/pur-group/bank-manage/edit.vue'

export default {
  name: 'BankManage',
  components: {
    editFrom
  },
  mixins: [adminSupport.mixins.index],
  data() {
    return {
      name: 'BankManage',
      formSearch: { supplierName: '', accountName: '', bankName: '', used: '' },
      self: null,
      mode: 'modal'
    }
  },
  created() {
    this.init()// 页面自定义初始化
  },
  methods: {
    init() {
      var that = this
      that.loadData()// 加载数据(按钮+列表) 扩展需重写该方法
      this.self = that
    },
    search() {
      const queryList = []
      if (!String.isNullOrEmpty(this.formSearch.supplierName)) {
        queryList.push({ 'key': 'o.name', 'value': {
          's.name': this.formSearch.supplierName,
          's.no': this.formSearch.supplierName
        }, 'oper': '=', 'join': 'andOr' })
      }
      if (!String.isNullOrEmpty(this.formSearch.accountName)) {
        queryList.push({ 'key': 'o.accountName', 'value': this.formSearch.accountName, 'oper': ':', 'join': 'and' })
      }
      if (!String.isNullOrEmpty(this.formSearch.bankName)) {
        queryList.push({ 'key': 'o.bankName', 'value': this.formSearch.bankName, 'oper': ':', 'join': 'and' })
      }
      if (!String.isNullOrEmpty(this.formSearch.used) && this.formSearch.used !== 'All') queryList.push({ 'key': 'o.used', 'value': this.formSearch.used, 'oper': '=', 'join': 'and' })

      this.dataGrid.params.queryList = queryList
      this.refresh()
    },
    bindSearch() {
      this.formSearch = { supplierName: '', accountName: '', bankName: '', used: '' }
    }
  }
}
</script>
